/**
 * @param {number[][]} image
 * @return {number[][]}
*/
var flipAndInvertImage = function(image) {
  for(let i = 0; i < image.length; i++) {
    for(let j = 0; j < Math.floor(image[i].length / 2); j++) {
      let temp = image[i][j];
      image[i][j] = image[i][image[i].length - 1 - j];
      image[i][image[i].length - 1 - j] = temp;
    }
    for(let j = 0; j < image[i].length; j++) {
      image[i][j] = image[i][j] ? 0 : 1;
    }
  }
  return image;
};
let image = [[1,1,0],[1,0,1],[0,0,0]];
console.log(flipAndInvertImage(image));
image = [[1,1,0,0],[1,0,0,1],[0,1,1,1],[1,0,1,0]];
console.log(flipAndInvertImage(image));
